<!DOCTYPE html>
<html>
<head>
	<% include global/meta.html %>
	<% include global/top-css.html %>
	<title>yscms后台管理系统</title>
</head>
<body>
	<div class="ys-wrap page-login pt-160 row">
		<div class="login-ad mt-35 col-12">
			<img src="/static/admin/img/banner.png" alt="">
		</div>
		<div class="login-form col-12">
			<div class="ys-logo mt-26 mb-30 text-c">
				<img src="/static/admin/img/logo.png" alt="">
			</div>
			<ul class="w-330">
				<form name="login" @submit.prevent="checkLogin" method="post">
				<li class="border-b pt-8 pb-8 mb-10 pos-r">
					<i class="ico ico-user pos-r t-2"></i>
					<input type="text" class="ml-10 f-14 lh-20 c-333" name="admin_user" v-model="form.admin_user" placeholder="用户名" >
				</li>
				<li class="border-b pt-8 pb-8  mb-10 pos-r">
					<i class="ico ico-pass pos-r t-2"></i>
					<input type="password" class="ml-10 f-14 lh-20 c-333" name="admin_pass" v-model="form.admin_pass" placeholder="密码" >
				</li>
				<li class="mt-21"><input type="submit" class="btn-block f-16 c-fff lh-22" value="登录"></li>
			</ul>
		</div>
	</div>

	<footer class="ys-footer">
		<p class="f-13 c-a1a3aa text-c">&copy;
			<a href="http://www.yuscms.com" class="mr-5" target="_blank" title="yuscms">yuscms.com</a>
			雨说科技 ● 位于北京 服务全国</p>
	</footer>

	<% include global/footer-js.html %>
	<script>
		var vm = new Vue({
			el:'.page-login',
			data:{
				form:{
					admin_user:'',
					admin_pass:''
				}
			},
			methods:{
				checkLogin:function(){
					var _this = this;
					var fm = document.login;
				
					if(fm.admin_user.value == '' || fm.admin_user.value.length<2){
						alert('用户名不得为空且不能小于两位！');
						fm.admin_user.focus();
						return false;
					}

					if(fm.admin_pass.value == '' || fm.admin_pass.value.length<6){
						alert('密码不得为空且不能小于六位！');
						fm.admin_pass.focus();
						return false;
					}

					_this.login();

				},
				login:function(){
				
					$.ajax({
						url: "/admin/login",
						data:vm.form,
						cache:false,
						type: "post",
						dataType:'json',
						success:function(data){
							console.log(data)
							if(data.success){
								location.href = '/admin/index'
							}else{
								alert(data.msg);
								return;
							}
						}
					});
				}
				
			},
			created:function(){
			
			},
			mounted:function(){
				
			},
			updated:function(){
				
			}
		});
	</script>
</body>
</html>